package encaps.utils;

import encaps.entities.MovieLocal;
import encaps.entities.MoviePersonInfo;
import encaps.entities.PersonLocal;
import java.util.HashSet;

public class PersonListBoxHelper {

    public static String createPersonListBox(Iterable<PersonLocal> items) {
        String res = "<select id=\"select-list\" name=\"sourcePersons\" size=\"10\" multiple=\"multiple\">\n";
        for (PersonLocal p : items) {
            res += " <option id=\"" + p.getId() + "\">" + p.getName() + "</option>";
        }
        res += "</select>";

        return res;
    }

    public static String createMovieListBox(MovieLocal m) {
        HashSet<MoviePersonInfo> set = m.getPersons();

        String res = "<select name=\"destinationPersons\" size=\"10\" multiple=\"multiple\">\n";
        for (MoviePersonInfo p : set) {
            res += " <option id=\"" + p.id + "\" title=" + p.type + ">" + p.name + "</option>";
        }
        res += "</select>";

        return res;
    }
}
